using System;
using System.Collections;
using System.Windows.Forms.Design;

namespace testLine
{
	/// <summary>
	/// LabelLineDesigner
	/// </summary>
	public class LabelLineDesigner : System.Windows.Forms.Design.ControlDesigner
	{
		private System.ComponentModel.Design.DesignerVerb verb = null;
		private System.ComponentModel.Design.DesignerVerbCollection _Verbs = null;

		#region Constructor
		public LabelLineDesigner():base()
		{
			verb = new System.ComponentModel.Design.DesignerVerb("About(&A)...",new System.EventHandler(OnAbout));
		}

		~LabelLineDesigner()
		{
			this.Dispose(true);
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				verb = null;
				_Verbs.Clear();
				_Verbs = null;
			}
			base.Dispose (disposing);
		}
		#endregion

		#region Control SelectionRules
		/// <summary>
		/// Set SelectionRules for Control
		/// </summary>
		/// <remarks>
		/// Override Property: SelectionRules to customize, ex: control sizing.
		/// </remarks>
		public override SelectionRules SelectionRules
		{
			get
			{
				SelectionRules selectionRules = SelectionRules.Moveable | SelectionRules.Visible;

				if (this.Control != null &&	this.Control is LabelLine)
				{
					LabelLine hline = (LabelLine)this.Control;


					if (hline.LineStyle == LineStyles.Horizontal)
						selectionRules |= SelectionRules.LeftSizeable | SelectionRules.RightSizeable;
					else
						selectionRules |= SelectionRules.TopSizeable | SelectionRules.BottomSizeable;

				}

				return selectionRules;
				
			}
		}
		#endregion

        #region FilterProperties
        /// <summary>
		/// Override PostFilterProperties to hide properties.
		/// </summary>
		protected override void PostFilterProperties(IDictionary properties)
		{

			foreach(string prop in unbrowsableProperties)
			{
				
				properties.Remove(prop);
			}
			base.PostFilterProperties (properties);
		}

		private static readonly string[] unbrowsableProperties = {  "AccessibleDescription",
																	 "DynamicProperties",
																	 "Visible",
																	 "Right",
																	 "Bounds",
																	 "BindingContext",
																	 "Top",
																	 "ClientSize",
																	 "BackColor",
																	 "Dock",
																	 "TopLevelControl",
																	 //"ForeColor",
																	 "Cursor",
																	 "BackgroundImage",
																	 "Height",
																	 "AccessibleRole",
																	 "ImeMode",
																	 "Modifiers",
																	 "AllowDrop",
																	 "RecreatingHandle",
																	 "Tag",
																	 "Locked",
																	 "Handle",
																	 "CanSelect",
																	 "TabIndex",
																	 "RightToLeft",
																	 "DataBindings",
																	 "Width",
																	 "Anchor",
																	 "TabStop",
																	 "IsAccessible",
																	 "Region",
																	 //"Font",
																	 "WindowTarget",
																	 "IsDisposed",
																	 "DisplayRectangle",
																	 "AccessibleDefaultActionDescription",
																	 "Parent",
																	 "Left",
																	 "ProductVersion",
																	 "CausesValidation",
																	 "ClientRectangle",
																	 "Site",
																	 "Name",
																	 "Enabled",
																	 "Disposing",
																	 "InvokeRequired",
																	 "Controls",
																	 "Container",
																	 "ContainsFocus",
																	 "AccessibilityObject",
																	 "ContextMenu",
																	 "HasChildren",
																	 "CanFocus",
																	 "Capture",
																	 "Focused",
																	 "IsHandleCreated",
																	 "CompanyName",
																	 "Created",
																	 "AccessibleName",
																	 "ProductName",
																	 "DrawGrid",
																	 "GridSize",
																	 "SnapToGrid",
																	 //"Text",
																	 "Bottom",
																	 //"Size"
		};

		#endregion

		#region Verbs
		public override System.ComponentModel.Design.DesignerVerbCollection Verbs
		{
			get
			{
				if (_Verbs == null)
				{
					_Verbs = new System.ComponentModel.Design.DesignerVerbCollection();
					_Verbs.Add(verb);
				}

				return _Verbs;
				
			}
		}

		private void OnAbout(object sender, EventArgs args) 
		{
            string strMsg = @"LabelLineDesigner";
			// Display a message
			System.Windows.Forms.MessageBox.Show(strMsg);
		}
		#endregion

	}

	

}
